using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace fotka.uploader
{
    public partial class ProgressForm : Form
    {
        public ProgressForm()
        {
            InitializeComponent();
        }

        private void btnAnuluj_Click(object sender, EventArgs e)
        {

        }

        private void ProgressForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            
            while (this.Opacity > 0)
            {
                this.Opacity = this.Opacity - 0.1;
                System.Threading.Thread.Sleep(50);
            }
            
            //zamkniecie strumienia jezeli taki jest ciagle otwarty
           // if (MainForm.thrUpload.IsAlive)
            //{
            MainForm MainForm = new MainForm();

            try
            {
                MainForm.requestStream.Close();
            }
            catch (Exception e1)
            {
                //obluga wylaczenia formy 
                //throw new Exception("dupa 1");
                MainForm.KillAllThread();
                Application.Exit();
            }
            try
            {
                MainForm.fileStream.Close();
            }
            catch (Exception f)
            {
                //throw new Exception("dupa");
                MainForm.KillAllThread();
                Application.Exit();
            }
              //  MainForm.thrUpload.Abort();
            //}
            Application.Exit();
        }

        private void ProgressForm_Shown(object sender, EventArgs e)
        {

        }

        private void ProgressForm_FormClosing(object sender, FormClosingEventArgs e)
        {

        }

        private void ProgressForm_Load(object sender, EventArgs e)
        {

        }
    }
}